#include<iostream>







using namespace std;
void move(int n,char x,char y,char z)
{
    if(n==1)
    {
        cout<<n<<"from "<<x<<"to "<<z<<endl;
        return ;

    }
    else{
        move(n-1,x,z,y);
                cout<<n<<"from "<<x<<"to "<<z<<endl;
        move(n-1,y,x,z);
    }
}
int main()
{
move(5,'A','B','Z');





    return 0;
}